<template>
  <!-- 只是一个点赞图标的样式 漏了只能这样补上去了 -->
  <b-link @click="toLike" class="iconfont text-decoration-none text-dark" :class="isLike?'icon-good-fill':'icon-good'" style="font-size:26px">
    <span style="font-size:16px">{{num}}</span>
  </b-link>
</template>
<script>
export default {
  props: {
    num: Number,
    id: String,
    isLikeInfo: Number,
    type: Number,
  },
  data() {
    return {
      //控制是否点赞
      isLike: false,
    }
  },
  created() {
    this.isLike = this.isLikeInfo == 1 ? true : false;
  },
  methods: {
    //点赞操作
    toLike() {
      if (this.type == 1) {
        this.$httpIssue.toLike(this.id, "comment").then((res) => {
          console.log(res);
          if (res == "1") {
            this.$httpIssue.isLike(this.id).then((res) => {
              console.log(res);
              this.isLike = res == "1" ? true : false;
            })
          }
        })
      } else {
        this.$httpIssue.toLike(this.id, "criticism").then((res) => {
          console.log(res);
          if (res == "1") {
            this.$httpIssue.isLike(this.id).then((res) => {
              console.log(res);
              this.isLike = res == "1" ? true : false;
            })
          }
        })
      }

    }
  },
}
</script>
<style scoped>
</style>
